package cn.edu.shu.wechat.core.task;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;

public class InitAccessToken implements ApplicationListener<ContextRefreshedEvent> {

	private static final Logger logger=LoggerFactory.getLogger(InitAccessToken.class);
	@Autowired
	private UpdateAccessToken updateAccessToken;

	@Override
	public void onApplicationEvent(ContextRefreshedEvent event) {
		if (event.getApplicationContext().getParent() == null) {
			logger.info("request access_token ...");
			updateAccessToken.sync();
		}
	}

}
